package com;


import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.netty.server.Server;
import com.netty.server.registry.ServiceRegistry;
import com.netty.user.UserService;
import com.netty.user.impl.UserServiceImpl;

@Configuration
public class Application {

	@Bean
	public UserService getUserService(){
		return new UserServiceImpl();
	}
	@Bean
	public Server getServer(){
		String serverAddress = "127.0.0.1:8081";
		String registryAddress = "127.0.0.1:2181";
		ServiceRegistry serviceRegistry = new ServiceRegistry(registryAddress);
		return new Server(serverAddress,serviceRegistry);
	}
	
	public static void main(String[] args) throws Exception {
		@SuppressWarnings("resource")
		AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Application.class);
		Server server = ctx.getBean(Server.class);
		server.start();
	}

}
